<%@ page import="java.util.regex.Pattern" %>
<%@ page import="java.util.regex.Matcher" %>
<%--
  Created by IntelliJ IDEA.
  User: bill
  Date: 2010-7-7
  Time: 18:22:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%!
    private String _page_getCountSql(String sql) {
        String s1 = "select";
        String s2 = "from";
        Pattern p1 = Pattern.compile(s1, Pattern.CASE_INSENSITIVE);
        Matcher m1 = p1.matcher(sql);
        Pattern p2 = Pattern.compile(s2, Pattern.CASE_INSENSITIVE);
        Matcher m2 = p2.matcher(sql);
        int whereStart = 0;
        m1.find();
        while (m2.find()) {
            if (m1.find() && m1.start() < m2.start()) {
                continue;
            } else {
                whereStart = m2.start();
                break;
            }
        }
        return "select count(1) " + sql.substring(whereStart);
    }

    private String _page_getPageSql(String sql) {
        return "select * from (select W.*, ROWNUM RN from(\\n" +
                sql +
                "\n) W where ROWNUM <= ? ) where RN >= ?";
    }
%>